<template>
  <div class="home">
    <img alt="Vue logo" src="../assets/logo.png" />
    <HelloWorld msg="Welcome to Your Vue.js App" />
    <img :src="'data:image/png;base64,' + url" alt="">
  </div>
</template>

<script>
// @ is an alias to /src
import HelloWorld from "@/components/HelloWorld.vue";

export default {
  name: "Home",
  components: {
    HelloWorld
  },
  data() {
    return {
      url: ''

    }
  },
  mounted() {
    const that = this;
    this.$http
      .get("/api/cgi-bin/token", {
        params: {
          grant_type: "client_credential",
          appid: "wx1d3901d63d1195f9",
          secret: "27551fad7e2421990c133a773cda39f9"
        }
      })
      .then(function(response) {
        console.log(response);
        that.$http.post(
          "/api/cgi-bin/wxaapp/createwxaqrcode?access_token=" +
            response.data.access_token,
          {
            path: "/pages/ideaPage/ideaPage?id=" + 12345, // 携参数openid
            width: "430"
          },
          {
responseType: "arraybuffer"
          }
          
        )
        .then(function(data) {
          console.log(data);
          that.url = data.data;
        })
      })
      .catch(function(error) {
        console.log(error);
      });
  }
};
</script>
